'use strict';
const { checkToken } = require('./action/checkToken')
const common = require('./action/common');
exports.main = async (event, context) => {
    // console.log('请求数据：', event)
    if (event.target.indexOf('login') < 0) {
        const token = event.token;
        if (!token) {
            return {
                state: 'noPass',
                msg: '未登录'
            }
        }
        var rs = checkToken(token)
        if (rs.state && rs.state === 'noPass') {
            return {
                state: 'noPass',
                msg: '未登录'
            }
        }
        rs = common.simplePosition(rs);
        event.userInfo = rs;
        // console.log('用户信息', rs)
        return await require(`./${event.target}`).main(event)
    } else {
        console.log(event)
        return await require(`./${event.target}`).main(event)
    }
};